const http = require('http');
const url = require('url');
const path = require('path');
const fs = require('fs').promises;
//第三方模块
const chalk = require('chalk');
const mime = require('mime');
const {createReadStream,readFileSync} = require("fs");
const ejs = require('ejs');
const zlib = require('zlib');
class Server{
    handleRequst(req,res){
        //1:获取请路径 以当前目录为基准查找文件，如果文件存在不是文件夹则直接返回
        let {pathname} = url.parse(req.url);
        try{
            if(){

            }else{
                res.end();
            }
        }catch(e){

        }
    }
    gzip(){//浏览器会给我发一个accept-encoding字段 我要看下浏览器支持什么压缩
        let encodings = req.headers['accept-encoding'];
        if(encodings){
            if(encodings.includes('gzip')){
                res.setHeader('Content');
                return zlib.createGzip();
            }else if(encodings.includes('deflate')){
            
            }
        }
    }
    start(){
        //启动服务
        Server.on('error',(err) => {
            if(err.error === "EADDRINUSE"){
                Server.listen(++this.port)
            }
        });
    }
}